package com.cam.framework.utils;

import com.cam.framework.component.StringObjectRedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class CacheUtils {

    static StringObjectRedisTemplate redisTemplate;

    public CacheUtils(StringObjectRedisTemplate redisTemplate) {
        CacheUtils.redisTemplate = redisTemplate;
    }

    public static void setCache(String key, Object value) {
        redisTemplate.opsForValue().set(key, value);
    }

    public static Object getCache(String key) {
        return redisTemplate.opsForValue().get(key);
    }

    public static <T> T getCache(String key, Class<T> type) {
        return (T) redisTemplate.opsForValue().get(key);
    }
}
